/**
 * 
 */
package commons.strings;

import java.nio.ByteBuffer;

import commons.Preconditions;

/**
 * @author armstrong
 * 
 */
public class StringsUtil {

	public static ByteBuffer byteBufferFromString(final String string) {

		Preconditions.checkNotNull("string must not be null.", string);

		return ByteBuffer.wrap(string.getBytes());
	}

	public static String generateStringWithChar(final char character,
			final int size) {

		Preconditions.checkIsNonNegative("size must be non-negative.", size);

		final StringBuilder builder = new StringBuilder();

		for (int currentSize = 0; currentSize < size; currentSize++) {

			builder.append(character);
		}

		return builder.toString();
	}
}
